import java.util.HashSet;
import java.util.Set;

public class hwSet {
    public static void main(String[] args) {
        // 创建HashSet并添加字符串
        Set<String> stringSet = new HashSet<>();
        
        String[] strings = {"apple", "banana", "apple", "orange", "banana", "pear"};
        
        System.out.println("添加前的集合大小: " + stringSet.size());
        
        boolean hasDuplicates = false;
        for (String str : strings) {
            if (!stringSet.add(str)) {
                System.out.println("发现重复元素: " + str);
                hasDuplicates = true;
            }
        }
        
        System.out.println("添加后的集合大小: " + stringSet.size());
        System.out.println("集合内容: " + stringSet);
        
        if (!hasDuplicates) {
            System.out.println("没有发现重复元素");
        }
    }
}